﻿//双击事件
function CustomDbClick() {
    //parent.closeWin(); //去掉双击功能
    fnViewDetail();
}

//新增分类
var fnAddTaskType = function () {
    //debugger;
    //alert("_key:" + _key + " _Caption:" + _Caption)
    var TaskTypeID = _key;
    if (TaskTypeID == null || TaskTypeID == "") {
        alert("请先选择上级分类！");
        return;
    }
    var TaskTypeName = _Caption;
    const_EditEntity = "SysTaskType";
    document.getElementById("dialog1_h").innerHTML = "新增分类";
    document.getElementById("EditUIWindow").src = "../Extend/AutoLoadForm.aspx?r=" + Math.random() + "&entity=" + const_EditEntity + "&TaskTypeID=" + TaskTypeID + "&TaskTypeName=" + TaskTypeName + "&flag=Add";
    SetDWH(550, 480, YAHOO.example.container.dialog1);
    YAHOO.example.container.dialog1.show();
    parent.NeedRefreshPage = this;
}

//保存成功回调
var CallBackParameter = function (obj) {
    //debugger;
    RefreshTreeData(obj.TaskType, obj.ID);
}

//删除技能分类
var fnDelTaskType = function () {
    //debugger;
    //alert("_key:" + _key + " _Caption:" + _Caption)
    var TaskTypeID = _key;
    if (TaskTypeID == null || TaskTypeID == "") {
        alert("请选择要删除的分类！");
        return;
    }
    var TaskTypeName = _Caption;
    const_EditEntity = "SysTaskType";

    if (confirm("删除后将无法恢复,确定要删除吗?")) {
        YAHOO.util.Connect.asyncRequest('POST', "../EHR/DatPostAjax.aspx?flag=isdelsystasktype" + "&id=" + TaskTypeID, {
            success: function (res) {
                try {
                    var str = res.responseText;
                    if (str == "1") {
                        deleteNode();
                    }
                    else if (str == "2") {
                        alert("有下级分类，不能删除！");
                        return;
                    }
                    else if (str == "3") {
                        alert("有引用了分类，不能删除！");
                        return;
                    }
                    else if (str == "4") {
                        alert("根目录，不能删除！");
                        return;
                    }                   
                    else if (str == "-1" || str == "0") {
                        alert("删除失败！");
                        return;
                    }
                }
                catch (e) {
                    alert("删除失败：" + e.Message);
                    return;
                }
                finally {
                }
            },
            failure: function (error) {
                alert("数据错误：" + error.statusText);
                return;
            }
        }, null);
    }
}

//新增预警
var fnCustomAdd = function () {
    var TaskTypeID = _key;
    if (TaskTypeID == null || TaskTypeID == "") {
        alert("请选择分类！");
        return;
    }
    var TaskTypeName = _Caption;

    //const_EditEntity = "datSkill";
    var pagetitle = "新增预警";
    parent._employeeTitle = pagetitle;
    parent.addTabs(pagetitle, encodeURI("../Extend/Edit.aspx?r=" + Math.random() + "&entity=" + const_EditEntity + "&flag=add" + "&TaskTypeID=" + TaskTypeID + "&TaskTypeName=" + TaskTypeName));
    parent.NeedRefreshPage = this;
}

//修改预警
var fnCustomEdit = function () {
    var recordID = myDataTable.getSelectedRows()[0];
    record = myDataTable.getRecord(recordID);
    if (record == null) {
        alert("请选择一条记录");
        return;
    }
    //const_EditEntity = "datSkill";
    //debugger
    var pagetitle = "修改预警_" + record._oData["TaskName"];
    parent._employeeTitle = pagetitle;
    parent.addTabs(pagetitle, encodeURI("../Extend/Edit.aspx?r=" + Math.random() + "&entity=" + const_EditEntity + "&flag=edit" + "&id=" + record.getData(const_entityID)));
    //parent.NeedRefreshPage = this;
}

//查看
var fnViewDetail = function () {
    var recordID = myDataTable.getSelectedRows()[0];
    record = myDataTable.getRecord(recordID);
    if (record == null) {
        alert("请选择一条记录");
        return;
    }
    //const_EditEntity = "SysTask";
    //debugger;
    var pagetitle = "查看预警_" + record._oData["TaskName"];
    parent._employeeTitle = pagetitle;
    parent.addTabs(pagetitle, encodeURI("../Extend/Edit.aspx?r=" + Math.random() + "&entity=" + const_EditEntity + "&flag=view" + "&id=" + record.getData(const_entityID)));
    parent.NeedRefreshPage = this;
}







